package com.mszlu.blog.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mszlu.blog.common.Result;
import com.mszlu.blog.entity.Comment;
import com.mszlu.blog.entity.SysUser;
import com.mszlu.blog.entity.dto.CommentDto;
import com.mszlu.blog.entity.mongo.MongoComment;
import com.mszlu.blog.service.CommentService;
import com.mszlu.blog.service.SysUserServive;
import com.mszlu.blog.service.mongo.MongoCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @Autowired
    private MongoCommentService mongoCommentService;

//    @GetMapping("/article/{id}")
//    public Result articleComments(@PathVariable Long id){
//
//        return commentService.viewsByArticleId(id);
//
////        return mongoCommentService.viewsByArticleId(id);
//    }
//
//    @PostMapping("/create/change")
//    public Result comment(@RequestBody Comment comment){
//
//        return commentService.comment(comment);
////        return mongoCommentService.comment(comment);
//    }

    @GetMapping("/article/{id}")
    public Result articleComments(@PathVariable Long id){

//        return commentService.viewsByArticleId(id);

        return mongoCommentService.viewsByArticleId(id);
    }

    @PostMapping("/create/change")
    public Result comment(@RequestBody MongoComment comment){

//        return commentService.comment(comment);
        return mongoCommentService.comment(comment);
    }




}
